// ignore_for_file: constant_identifier_names

import 'package:flutter/widgets.dart';
import '../lorin/lorin_vehicle_product_model.dart';

// Lorin车辆类型
enum LorinVehicleType {
  eBike, // 电动自行车
  wiggle, // 扭扭车
  euc, // 独轮车
  dulWheelScv, // 双轮车
  scooter, // 滑板车
  v5,
  v6,
  v8,
  v9,
  v10,
  v11,
  v12,
  v12s,
  p6,
  l8,
  ls1,
  la1,
  lc1,
  le1,
  lr1,
  rsJet,
  unknown; // 未知类型

  // 根据产品型号获取车辆类型
  static LorinVehicleType fromProductModel(LorinProductModel productModel) {
    final productHelper = _LorinProductHelper(productModel);
    if (productHelper.isEBike) {
      return LorinVehicleType.eBike;
    } else if (productHelper.isWiggle) {
      return LorinVehicleType.wiggle;
    } else if (productHelper.isEuc) {
      if (productHelper.isV5) {
        return LorinVehicleType.v5;
      } else if (productHelper.isV6) {
        return LorinVehicleType.v6;
      } else if (productHelper.isV8) {
        return LorinVehicleType.v8;
      } else if (productHelper.isV9) {
        return LorinVehicleType.v9;
      } else if (productHelper.isV10) {
        return LorinVehicleType.v10;
      } else if (productHelper.isV11) {
        return LorinVehicleType.v11;
      } else if (productHelper.isV12) {
        return LorinVehicleType.v12;
      } else if (productHelper.isV12s) {
        return LorinVehicleType.v12s;
      } else if (productHelper.isP6) {
        return LorinVehicleType.p6;
      } else {
        debugPrint('未知独轮车型号: ${productModel.subSeries}');
        return LorinVehicleType.unknown; // 默认独轮车
      }
    } else if (productHelper.isDulWheelScv) {
      return LorinVehicleType.dulWheelScv;
    } else if (productHelper.isScooter) {
      if (productHelper.isL8) {
        return LorinVehicleType.l8;
      } else if (productHelper.isLS1) {
        return LorinVehicleType.ls1;
      } else if (productHelper.isLA1) {
        return LorinVehicleType.la1;
      } else if (productHelper.isLC1) {
        return LorinVehicleType.lc1;
      } else if (productHelper.isLE1) {
        return LorinVehicleType.le1;
      } else if (productHelper.isLR1) {
        return LorinVehicleType.lr1;
      } else if (productHelper.isRsJec) {
        return LorinVehicleType.rsJet;
      } else {
        debugPrint('未知滑板车型号: ${productModel.subSeries}');
        return LorinVehicleType.unknown; // 默认滑板车
      }
    } else {
      debugPrint('未知车辆类型: ${productModel.mainSeries}');
      return LorinVehicleType.unknown; // 未知类型
    }
  }
}

// Lorin产品助手
class _LorinProductHelper {
  // 产品型号
  final LorinProductModel productModel;
  _LorinProductHelper(this.productModel);

  // 是否是独轮车
  bool get isEBike => productModel.mainSeries == _Lorin.eBike;

  // 是否扭扭车
  bool get isWiggle => productModel.mainSeries == _Lorin.wiggle;

  // 是否是独轮车
  bool get isEuc => productModel.mainSeries == _Lorin.euc;

  // 是否是双轮车
  bool get isDulWheelScv => productModel.mainSeries == _Lorin.dulWheelScv;

  // 是否是滑板车
  bool get isScooter => productModel.mainSeries == _Lorin.scooter;

  // 是否是V5
  bool get isV5 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.V5;

  // 是否是V6
  bool get isV6 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.V6;

  // 是否是V8
  bool get isV8 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.V8;

  // 是否是V9
  bool get isV9 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.V9;

  // 是否是V10
  bool get isV10 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.V10;

  // 是否是V11
  bool get isV11 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.V11;

  // 是否是V12
  bool get isV12 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.V12;

  // 是否是V12S
  bool get isV12s =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.V12S;

  // 是否是V13
  bool get isV13 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.V13;

  // 是否是V14
  bool get isV14 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.V14;

  // 是否是E20
  bool get isE20 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.E20;

  // 是否是P6
  bool get isP6 =>
      productModel.mainSeries == _Lorin.euc &&
      productModel.subSeries == _Lorin.P6;

  // 是否是R1
  bool get isR1 =>
      productModel.mainSeries == _Lorin.dulWheelScv &&
      productModel.subSeries == _Lorin.R1;

  // 是否是E2
  bool get isE2 =>
      productModel.mainSeries == _Lorin.dulWheelScv &&
      productModel.subSeries == _Lorin.E2;

  // 是否是E3
  bool get isE3 =>
      productModel.mainSeries == _Lorin.dulWheelScv &&
      productModel.subSeries == _Lorin.E3;

  // 是否是L8
  bool get isL8 =>
      productModel.mainSeries == _Lorin.scooter &&
      productModel.subSeries == _Lorin.L8;

  // 是否是LS1
  bool get isLS1 =>
      productModel.mainSeries == _Lorin.scooter &&
      productModel.subSeries == _Lorin.LS1;

  // 是否是LA1
  bool get isLA1 =>
      productModel.mainSeries == _Lorin.scooter &&
      productModel.subSeries == _Lorin.LA1;

  // 是否是LC1
  bool get isLC1 =>
      productModel.mainSeries == _Lorin.scooter &&
      productModel.subSeries == _Lorin.LC1;

  // 是否是LE1
  bool get isLE1 =>
      productModel.mainSeries == _Lorin.scooter &&
      productModel.subSeries == _Lorin.LE1;

  // 是否是LR1
  bool get isLR1 =>
      productModel.mainSeries == _Lorin.scooter &&
      productModel.subSeries == _Lorin.LR1;

  // 是否是RS_Jet
  bool get isRsJec =>
      productModel.mainSeries == _Lorin.scooter &&
      productModel.subSeries == _Lorin.RS_JET;
}

// Lorin车辆类型常量
class _Lorin {
  /// ===== 主系列 =====
  static const int dulWheelScv = 1; // 双轮平衡车
  static const int euc = 2; // 独轮平衡车
  static const int scooter = 3; // 电动滑板车
  static const int eBike = 4; // 电动车
  static const int wiggle = 5; // 扭扭车

  /// ===== 子系列 =====
  // 双轮系列
  static const int R1 = 1;
  static const int E2 = 3;
  static const int E3 = 4;

  // 独轮系列
  static const int V5 = 3;
  static const int V8 = 4;
  static const int V10 = 5;
  static const int V11 = 6;
  static const int V12 = 7;
  static const int V13 = 8;
  static const int V14 = 9;
  static const int E20 = 10;
  static const int V12S = 11;
  static const int V9 = 12;
  static const int P6 = 13;
  static const int V6 = 14;

  // 滑板系列
  static const int L8 = 4;
  static const int LS1 = 5;
  static const int LA1 = 6;
  static const int LC1 = 7;
  static const int LE1 = 8;
  static const int LR1 = 9;
  static const int RS_JET = 10;
}
